<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>微信安全支付</title>
</head>
<body>

<script type="text/javascript" src="http://res.wx.qq.com/open/js/jweixin-1.4.0.js"></script>

<!-- 
<p>#(sayHello)</p>
 -->
<script type="text/javascript">

//var hhh = JSON.stringify(#(sayHello));
//alert(hhh);
var obj=#(sayHello);
//alert(obj.xx);

function onBridgeReady(){
WeixinJSBridge.invoke('getBrandWCPayRequest', 
		{"appId":obj.appId,     
        "timeStamp":obj.timeStamp, 
        "nonceStr":obj.nonceStr,
        "package":obj.pg,
        "signType":obj.signType,
        "paySign":obj.paySign}, 
    function(res){
        if(res.err_msg == "get_brand_wcpay_request:ok" ) {
        	alert('支付成功; 订单号:' + '#(merchOrder)');
        	var url = "ourWxFont?merchOrder=" + '#(merchOrder)' + "&orderNo=" + '#(trorder)' ;
    		//微信支付成功返回前端通知
    		window.location.href = url;
        }else if(res.err_msg == "get_brand_wcpay_request:cancel"){
        	alert('支付取消');
        }else if(res.err_msg == "get_brand_wcpay_request:fail"){
        	alert('支付失败' + res.err_msg + ':' + JSON.stringify(res));
        }else{
        	alert('支付失败VVVVV' + res.err_msg + ':' + JSON.stringify(res));
        }
    });
}


if (typeof WeixinJSBridge == "undefined") {
	if (document.addEventListener) {
		document.addEventListener('WeixinJSBridgeReady',
				onBridgeReady, false);
	} else if (document.attachEvent) {
		document.attachEvent('WeixinJSBridgeReady',
				onBridgeReady);
		document.attachEvent('onWeixinJSBridgeReady',
				onBridgeReady);
	}
} else {
	onBridgeReady();
}


    
//alert(obj.appId);



</script>

</body>
</html>